import React from 'react';
import {ModalForm, ProFormDigit, ProFormRadio, ProFormText, ProFormTextArea} from "@ant-design/pro-form";
import {Button, message, Space} from "antd";
import {distributionLevelAddData} from "@/services/ant-design-pro/distribution";


const LevleAddData = (props) => {
  const {actionRef} = props

  return (
    <div style={{display:'inline-block'}}>
      <ModalForm
        layout='horizontal'
        // labelAlign='left'
        labelCol={{span:4}}
        wrapperCol={{span:14}}
        title='添加分销员等级'
        trigger={
          <Button type="primary">
            +添加数据
          </Button>
        }
        onFinish={async (values) => {
          // await waitTime(2000);
          // console.log(values);
          await distributionLevelAddData(values)
          message.success('提交成功');
          // 刷新
          actionRef.current?.reload()
          return true;
        }}
      >

          <ProFormText
            width="md"
            name="position"
            label="等级名称"
            placeholder="请输入等级名称"
          />
          <ProFormDigit
            width={100}
            name="level"
            label="等级"
          />
          <ProFormTextArea
            name="image"
            label="背景图"
            placeholder="请输入图片地址"
          />
          <ProFormDigit
            width={100}
            name="first_commission"
            tooltip="在分销一级佣金基础上浮（0-1000之间整数）百分比"
            label="一级上浮"
          />
          <ProFormDigit
            width={100}
            name="second_commission"
            tooltip="在分销二级佣金基础上浮（0-1000之间整数）百分比"
            label="二级上浮"
          />
          <ProFormRadio.Group
            name="is_show"
            label="是否显示"
            initialValue='1'
            options={[
              {
                label: '显示',
                value: '1',
              },
              {
                label: '隐藏',
                value: '0',
              },
            ]}
          />

      </ModalForm>
    </div>
  );
};

export default LevleAddData;
